/**
 * 
 */
package com.taobao.wolfwolf.hibernate.service.impl;

import java.util.List;

import com.taobao.wolfwolf.hibernate.dao.TypeDao;
import com.taobao.wolfwolf.hibernate.pojo.Type;
import com.taobao.wolfwolf.hibernate.service.TypeService;

/**
 * @author Tux
 *
 * 创建时间: 2011-4-30 上午01:44:34
 */
public class TypeServiceImpl extends BaseServiceImpl implements TypeService {
	private TypeDao tdao;

	public List<Type> findAll() {
		try {
			return tdao.findAll();
		} catch(Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public Type findById(int id) {
		try {
			return tdao.findById(id);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("Error at findById(int id)");
		}
		return null;
	}

	public List<Type> findByName(String name) {
		try {
			return tdao.findByName(name);
		}  catch (Exception e) {
			e.printStackTrace();
			System.out.println("Error at findByName(String name)");
		}
		return null;
	}

	public long getTotal()  {
		try {
			return tdao.getTotal();
		}  catch (Exception e) {
			e.printStackTrace();
			System.out.println("Error at getTotal()");
		}
		return -1;
	}

	public List<Type> paging(int page, int limit)  {
		try {
			return tdao.paging(page, limit);
		}  catch (Exception e) {
			e.printStackTrace();
			System.out.println("Error at paging(int page, int limit)");
		}
		return null;
	}

	public void settdao(TypeDao tdao) {
		this.tdao = tdao;
	}

	public TypeDao gettdao() {
		return tdao;
	}

	public List<Type> findByCategoryId(int id) {
		try {
			return tdao.findByCategoryId(id);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("Error at findByCategoryId(int id)");
		}
		
		return null;
	}

	public List<Type> findByCategoryName(String name) {
		try {
			return tdao.findByCategoryName(name);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("Error at findByCategoryName(String name)");
		}
		
		return null;
	}

	@Override
	public Integer getMaxId() {
		try {
			return tdao.getMaxId();
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("获取类别最大id出错");
		}
		return null;
	}
}
